package KeTangLian;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Scanner;

import javax.management.Query;

public class Demo3 {
	public static void main(String[] args) { 
		
		String sqlString="UPDATE newsinfo SET newstitle='车票实名制试运行' WHERE newsid=4";
		int result=DBManager.excuteUpdate(sqlString);
		String sqlString1="UPDATE newsinfo SET newstitle='神州七号发射成功' WHERE newsid=7";
		int result1=DBManager.excuteUpdate(sqlString1);
		String sqlString2="insert into newsinfo values(9,'欧美开打利比亚','管理员','国家',200,'2011-03-20 00:00:00')";
		int result2=DBManager.excuteUpdate(sqlString2);
		
		System.out.println("\t\t"+"新闻标题列表");
		System.out.println("编号\t标题\t\t创建者\t创建时间");
		String sql="SELECT newsid,newstitle,newsauthor,addtime from newsinfo where newsid=4 or newsid=7 or newsid=9";
		QueryDataResult rSet1=DBManager.excuteQuery(sql);
		try {
		if (rSet1.rs!=null) {
				while (rSet1.rs.next()) {
					System.out.println(rSet1.rs.getInt("newsid")+"\t"+rSet1.rs.getString("newstitle")
							+"\t"+rSet1.rs.getString("newsauthor")+"\t"+rSet1.rs.getString("addtime"));
				}
			} else {
				System.out.println("没有符合的数据");
			   }
			}catch (SQLException e) {
				e.printStackTrace();
		}
		rSet1.close();
	}

}
